package com.nopay.dxdwphone.ui.adapter;

import android.graphics.Color;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.nopay.dxdwphone.bean.response.GetCallTaskCallResponse;

import java.util.List;
import com.nopay.dxdwphone.R;

/**
 * author：jun
 * date：2021/7/20
 */
public class CallLogAdapter extends BaseQuickAdapter<GetCallTaskCallResponse.Data, BaseViewHolder> {

    private static final String[] STATUS_NAME = {"未拨打", "已接通", "未接通", "空号/停机", "拒接", ""};

    public CallLogAdapter(@Nullable List<GetCallTaskCallResponse.Data> data) {
        super(R.layout.adapter_call_log, data);
    }

    @Override
    protected void convert(@NonNull BaseViewHolder helper, GetCallTaskCallResponse.Data bean) {
        helper.setText(R.id.tv_name, bean.getName())
                .setText(R.id.tv_tel_num, bean.getCalledNumber())
                .setText(R.id.tv_status, STATUS_NAME[bean.getStatus()])
                .setTextColor(R.id.tv_status, bean.getStatus() == 1 ? Color.parseColor("#999999") : Color.RED)
                .setText(R.id.tv_talk_time, bean.getDuration() + "秒")
                .setText(R.id.tv_call_data, bean.getCallDate())
                .addOnClickListener(R.id.iv_dialed, R.id.iv_copy);
    }
}
